/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2017-2025 Ta4j Organization & respective
 * authors (see AUTHORS)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package org.ta4j.core.indicators.averages;

import static org.ta4j.core.TestUtils.*;

import org.junit.Test;
import org.ta4j.core.BarSeries;
import org.ta4j.core.Indicator;
import org.ta4j.core.indicators.AbstractIndicatorTest;
import org.ta4j.core.indicators.helpers.ClosePriceIndicator;
import org.ta4j.core.mocks.MockBarSeriesBuilder;
import org.ta4j.core.num.Num;
import org.ta4j.core.num.NumFactory;

public class WildersMAIndicatorTest extends AbstractIndicatorTest<Indicator<Num>, Num> {

    public WildersMAIndicatorTest(NumFactory numFunction) {
        super(numFunction);
    }

    @Test
    public void testCalculateWildersWithAAPL() {

        /*
         * Retrieved data from TradingView using AAPL and
         * "WILDER'S Moving Average by KivanceOzbilgic"
         */

        BarSeries data = new MockBarSeriesBuilder().withNumFactory(numFactory)
                .withData(174.65314694, 173.92766158, 176.86935564, 177.96255276, 174.40469305, 172.85434077,
                        173.70902216, 174.99104423, 170.89652411, 169.3759863, 169.63437835, 170.15116244, 172.67545397,
                        171.33380296, 172.58601057, 173.82828002, 176.39232417, 177.88304752, 177.28675818,
                        178.68803812, 179.59241029, 177.74391334, 177.61471732, 176.05442688, 174.7525285, 174.37487858,
                        171.81083443, 171.9300923, 172.36737115, 170.04184273, 165.85787921, 167.17965391, 169.23685212,
                        169.71388359, 172.89409339, 176.47182942, 175.5575191, 178.12156325, 180.69554556, 181.75892821,
                        181.28189674, 185.49127542, 183.89907563, 186.52620528, 187.09342645, 188.78513873,
                        188.76523623, 190.516656, 189.71060486, 190.37733852, 189.0438712, 188.86474872, 189.47177489,
                        188.44679627, 189.0239687, 190.30767978, 188.50650377, 192.47705199, 191.38241464, 193.32290813,
                        194.75588794, 192.23822202, 193.76076307, 196.99491889, 197.14418762, 196.60682019,
                        194.93501041, 195.97989153, 193.88017805, 193.73090932, 192.65617447, 192.10885579,
                        192.20836828, 192.63627197, 191.59139086, 184.73498052, 183.35175695, 181.02316476, 180.2967236,
                        184.65537053, 184.23741808, 185.28229919, 184.68522427, 185.01361548, 182.73477953,
                        181.78941091, 187.71040387, 190.62611974, 192.94476068, 194.22847176, 193.55178685,
                        193.22339564, 191.48192712, 190.79529096, 187.1232802, 183.50102568, 185.94903286, 184.94395674,
                        186.76503525, 188.37713753, 188.48660127, 187.40191516, 188.16913974, 186.47526874,
                        184.37287592, 183.48608463, 183.19713017, 181.65271838, 180.90542235, 181.66268233,
                        183.70529147, 181.86196127, 180.50686447, 181.97156468, 180.76592709, 180.09834264,
                        179.01227242, 174.46871257, 169.50666694, 168.51027224, 168.39070488, 170.11446771,
                        172.12718501, 172.60545447, 170.5130256, 172.37628369, 171.9976537, 173.09368788, 175.44517938,
                        178.02584166, 170.75216032, 171.6588795, 170.23403508, 169.09814512, 172.68516605, 170.86176374,
                        169.41699142, 168.23128172, 169.03836143, 168.21135383, 168.96861381, 167.84268779,
                        169.05828933, 167.17510334, 174.40892889, 175.91348489, 172.06740133, 168.76933486,
                        167.39431017, 166.43777126, 164.40512606, 165.24209761, 166.298276, 168.41063277, 169.27749616,
                        168.68962329, 172.87448104, 169.71590983, 168.68962329, 172.40617553, 182.71886071,
                        181.05488156, 181.7423939, 182.0811681, 183.90457041, 182.63743286, 185.86015293, 187.007561,
                        189.29239969, 189.41212923, 189.44206161, 190.60942461, 191.91647206, 190.46974014,
                        186.45880062, 189.55181369, 189.56179115, 189.86111499, 190.85886114, 191.81669745, 193.5926856,
                        193.91196436, 195.42853851, 194.04167136, 196.44623959, 192.6847366, 206.68311509, 212.5897723,
                        213.7571353, 212.01107954, 216.18165845, 213.80702261, 209.20741285, 207.02234878, 207.67088378,
                        208.5987877, 212.76936661, 213.61745084, 210.14529423, 216.26147814, 219.77354459, 221.05065966,
                        225.82986372, 227.30652802, 228.16458971, 232.45489816, 227.05709149, 230.02039755,
                        233.87169769, 234.29075108, 228.36413894, 223.67473204, 223.80443904, 223.45522788,
                        224.50286134, 218.04744375, 216.99981029, 217.46875098, 217.7481199, 218.30685775, 221.57946512,
                        217.86784944, 219.36446867, 208.79833693, 206.76293478, 209.34709731, 212.82923138, 215.7526276,
                        217.29093453, 221.02682427, 221.47632972, 224.47303272, 225.80157105, 225.64174689,
                        226.26106551, 226.1511864, 224.28324153, 226.59070284, 226.93032918, 227.77939503, 226.24108749,
                        229.53746079, 228.748329, 222.52517577, 220.60728585, 222.13560438, 220.57731882, 220.66721991,
                        219.86809911, 222.41529666, 222.52517577, 222.2554725, 216.08226432, 216.55174779, 220.44746169,
                        228.61847187, 227.9492082, 226.22110947, 227.12012037, 226.12121937, 227.26995552, 227.53965879,
                        232.743933, 225.96139521, 226.53076878, 225.42198867, 226.5507468, 221.44636269, 225.52187877,
                        229.28773554, 228.78828504, 227.29992255, 231.0458013, 233.59299885, 231.52527378, 231.89486715,
                        234.741735, 236.22010848, 235.60078986, 230.50639476, 230.31660357, 231.15568041, 233.1434934,
                        233.41319667, 229.8471201, 225.66172491, 222.66502191, 221.76601101, 223.20442845, 222.47523072,
                        227.22999948, 226.96, 224.23, 224.23, 225.12, 228.22, 225, 228.02, 228.28, 229)
                .build();

        var wildersMa = new WildersMAIndicator(new ClosePriceIndicator(data), 14);

        double[] expectedDoubles = { 174.65314694, 179.52201922069, 179.332543250641, 179.234686787024,
                178.889687234379, 178.458591058352, 178.119336137041, 177.89588671511, 177.395932243316,
                176.823078961651, 176.309600346533, 175.869711924638, 175.641550642163, 175.333854379152,
                175.137579821355, 175.044058406973, 175.140363104332, 175.336269134022, 175.475589780164,
                175.705050375866, 175.982718941162, 176.108518541079, 176.216104168144, 176.20455579042,
                176.10083955539, 175.977556628576, 175.679933614392, 175.412087806221, 175.194608045063,
                174.826553379701, 174.185933796151, 173.685485232855, 173.367725724793, 173.10673700088,
                173.091548171531, 173.332996832136, 173.491891279841, 173.822582134852, 174.313508093791,
                174.845323816378, 175.305079025208, 176.032664481979, 176.594550992552, 177.303954870226,
                178.00320284021, 178.773341118052, 179.487047911763, 180.274877060923, 180.948857618, 181.622320539571,
                182.15243130103, 182.631882545242, 183.120446284154, 183.500899854571, 183.895404772102,
                184.353424415523, 184.650072940843, 185.209142872926, 185.650090856288, 186.198149232982,
                186.809416283483, 187.197188121806, 187.66601490382, 188.332365188547, 188.961781076508, 189.5078552989,
                189.895509235407, 190.330107970735, 190.583684404968, 190.808486184614, 190.940463919284,
                191.023920481478, 191.108523895658, 191.217648758111, 191.244344622532, 190.77939004378,
                190.248844822795, 189.589867675453, 188.926071670063, 188.62102158863, 188.307907052299,
                188.091792204992, 187.848465923921, 187.645976606499, 187.29517681532, 186.901907822083,
                186.959657539791, 187.221547696949, 187.63034862431, 188.101643134002, 188.490939113716,
                188.828971722736, 189.018468536827, 189.145384424196, 189.000948408182, 188.608096784741,
                188.418163647259, 188.170006011026, 188.069650956667, 188.091614283334, 188.119827639524,
                188.068548176701, 188.075733288365, 187.961414392054, 187.705090215478, 187.403732673658,
                187.103261066254, 186.713936588665, 186.299042714474, 185.967874115583, 185.80626106947,
                185.524525369508, 185.166121019543, 184.937938423862, 184.6399376143, 184.315537973279,
                183.936733290902, 183.260446096551, 182.278033299655, 181.294621795394, 180.372913444294,
                179.640167320416, 179.103525726815, 178.6393777799, 178.058924052764, 177.653021169709,
                177.249066350444, 176.952253602556, 176.844605443802, 176.928979459244, 176.487778092155,
                176.142856764144, 175.72079807242, 175.247751432961, 175.064709619893, 174.7644991999, 174.382534358479,
                173.943159170016, 173.592816474301, 173.208426285422, 172.905582537178, 172.543947198093,
                172.294971636087, 171.929266757795, 172.106385481524, 172.378321153558, 172.356112594732,
                172.099914185109, 171.763799612601, 171.383369015986, 170.884923090559, 170.481864127662,
                170.183036404257, 170.056436144668, 170.000797574334, 169.90714226831, 170.119095037717,
                170.090296094308, 169.990248036858, 170.162814286368, 171.059674745199, 171.773618089113,
                172.485673504177, 173.171065975307, 173.937744863499, 174.559151148963, 175.366365561895,
                176.197879521759, 177.133202390919, 178.010268593711, 178.826825237732, 179.668439478608,
                180.543298948707, 181.252330462371, 181.624221187916, 182.190477795208, 182.717000177693,
                183.227294092858, 183.772406024796, 184.346998269454, 185.00740450735, 185.643444496825,
                186.34237978348, 186.892329181803, 187.574751353817, 187.939750299973, 189.278562070689,
                190.94364851564, 192.573183285951, 193.961604446955, 195.548751161458, 196.852913407783,
                197.735377653655, 198.398732734108, 199.061029237386, 199.742297699002, 200.672802621216,
                201.597420351129, 202.207982771048, 203.211803868831, 204.394785348914, 205.584490656849,
                207.030588732788, 208.478870110446, 209.884992938986, 211.497129026201, 212.608554916472,
                213.852257961724, 215.282217942316, 216.639970309293, 217.477410925772, 217.920076719645,
                218.340388313957, 218.705733997245, 219.119814521728, 219.043216609462, 218.897259015214,
                218.795222726985, 218.720429667914, 218.690888816635, 218.897215695447, 218.823689534343,
                218.862316615462, 218.143460923643, 217.330566199097, 216.760318421304, 216.479526489783,
                216.427605140512, 216.489271525476, 216.813382435799, 217.146450098956, 217.669777429031,
                218.250619830529, 218.778557477634, 219.313022337088, 219.801462627296, 220.121589691775,
                220.583669202363, 221.037002057908, 221.518601555915, 221.855921979778, 222.404603323365,
                222.857726585982, 222.833972956269, 222.67492387725, 222.636401056018, 222.489323753445,
                222.359173478913, 222.181239595419, 222.197957957175, 222.221330658091, 222.223769361085,
                221.785090429579, 221.411280241037, 221.34243605882, 221.862152902476, 222.296942566585,
                222.577240202543, 222.901731643076, 223.131695052142, 223.42728508556, 223.721026064449,
                224.365519416988, 224.47951054506, 224.626028990413, 224.682883253241, 224.816302078009,
                224.575592121723, 224.643184025171, 224.974937704802, 225.247319657316, 225.393934149651,
                225.797638946104, 226.354450367811, 226.723794897253, 227.093157201021, 227.639484186662,
                228.252385921901, 228.777271917479, 228.900780691945, 229.00191089752, 229.155751576983,
                229.440590278627, 229.724347878011, 229.733117322439, 229.442303578693, 228.958212030929,
                228.444483386577, 228.07019374825, 227.670553531947, 227.639085385379, 227.590579286423,
                227.350537908822, 227.127642343906, 226.984239319341, 227.072507939388, 226.924471658003,
                227.002723682432, 227.093957705115, 227.230103583321 };

        // skip the first 148 due to inaccuracies of the Wilder's calculation
        // See WildersMAIndicator.java javaDoc
        // @ element 149 the data starts to stabilize to 0.0001d
        for (int i = 149; i < data.getBarCount(); i++) {
            assertNumEquals(expectedDoubles[i], wildersMa.getValue(i));
        }

    }

    @Test
    public void testCalculateWildersWithNQ() {

        /*
         * Retrieved data from TradingView using NQ and
         * "WILDER'S Moving Average by KivanceOzbilgic"
         */

        BarSeries data = new MockBarSeriesBuilder().withNumFactory(numFactory)
                .withData(20563, 20568.25, 20566.75, 20564.25, 20557.75, 20580.25, 20601.5, 20609.5, 20616.25, 20605,
                        20620.25, 20640, 20638, 20640, 20667, 20664.25, 20672, 20676, 20677.75, 20688, 20687.25,
                        20695.75, 20695, 20702.25, 20692.75, 20694.25, 20689, 20697.5, 20700, 20690.25, 20680, 20681.5,
                        20679.75, 20673.25, 20656.75, 20657, 20657, 20660.5, 20653.25, 20639, 20638.75, 20630.75,
                        20630.75, 20623.75, 20624.25, 20626, 20612.25, 20596.75, 20592.5, 20589, 20592, 20594.25, 20604,
                        20616, 20629, 20622.5, 20630.25, 20628, 20634.75, 20637.75, 20630, 20638, 20641.75, 20643,
                        20648.75, 20648.25, 20648, 20650.75, 20651.5, 20640.5, 20632.5, 20629.75, 20631.75, 20646,
                        20641.5, 20639.25, 20652.75, 20648, 20657.75, 20652.25, 20635.25, 20609.75, 20622, 20615,
                        20618.5, 20606.5, 20607.25, 20620, 20623.5, 20616.25, 20619.25, 20624.25, 20620.5, 20619.25,
                        20616.75, 20612.25, 20609.75, 20612.75, 20616.25, 20619.5, 20622, 20615.75, 20617.75, 20620.75,
                        20623.25, 20605.75, 20595.75, 20585, 20603, 20600.75, 20608, 20619.5, 20619, 20621.25, 20625.25,
                        20627.75, 20627.5, 20622.75, 20617.25, 20609, 20612.25, 20605.25, 20610, 20604, 20602.5,
                        20591.5, 20587.5, 20591.25, 20582, 20568.25, 20569.25, 20572.75, 20569.75, 20560.5, 20559.5,
                        20572.25, 20574.75, 20575.75, 20574.75, 20574.5, 20571.5, 20577, 20578.25, 20585, 20587.5,
                        20585.75, 20589.75, 20581, 20586, 20589.75, 20592, 20588.5, 20583.25, 20570.5, 20567.75, 20577,
                        20570.25, 20569.75, 20571.25, 20569.5, 20574.75, 20573.5, 20577.5, 20569, 20567.75, 20566.25,
                        20567, 20573.25, 20567.25, 20561, 20560.25, 20560, 20568, 20573.25, 20569.5, 20570.5, 20572.5,
                        20571.75, 20571.75, 20568.75, 20574, 20583.25, 20582.75, 20590.5, 20590.75, 20590, 20588.75,
                        20597.75, 20599.5, 20602.5, 20618, 20619.25, 20619.25, 20616, 20619.5, 20625.75, 20620.5,
                        20619.25, 20612.25, 20617, 20606, 20608.5, 20607.25, 20605, 20608.25, 20607.75, 20609, 20603.75,
                        20609.5, 20599.75, 20604.5, 20605.25, 20611.25, 20605.25, 20598, 20605.25, 20610.5, 20613.25,
                        20615.5, 20617, 20610.25, 20612.5, 20618.5, 20617.5, 20618, 20619.75, 20619.75, 20628.75,
                        20631.25, 20627, 20630.5, 20635.75, 20642, 20647, 20646.75, 20649.5, 20655, 20674.5, 20682.25,
                        20697.25, 20710.25, 20720.25, 20721.25, 20713, 20727, 20729.25, 20725.5, 20728.75, 20727.75,
                        20717.25, 20704.5, 20711, 20704.5, 20717, 20727.5, 20735.5, 20728.75, 20746.5, 20738.25, 20728,
                        20737.75, 20738.5, 20759.25, 20753.5, 20744, 20741.25, 20752.25, 20772.5, 20781.25, 20780.25,
                        20781.75, 20777, 20764, 20775.25, 20781, 20769, 20767, 20769.25, 20774, 20772, 20763.75,
                        20769.5, 20769.25, 20770.5, 20766.75, 20770, 20769, 20642.5, 20631.25, 20691.5, 20737.5,
                        20717.25, 20696.25, 20680.25, 20694, 20671, 20661, 20652, 20649, 20680, 20691, 20712.5,
                        20702.25, 20685.75, 20694.25, 20700, 20691.75, 20692.75, 20701.75, 20709.5, 20709.75, 20711.75,
                        20732.5, 20730.75, 20725, 20727.5, 20728.75, 20723.25, 20716.75, 20719.75, 20719, 20721.25,
                        20726.25, 20731, 20733.25, 20741.75, 20738.75, 20723, 20719.5, 20726.25, 20719.5, 20730,
                        20730.5, 20728.5, 20730, 20731.5, 20728, 20729.25, 20719.5, 20712.75, 20711.25, 20707.25, 20698,
                        20700, 20702, 20706, 20697, 20702.25, 20704.5, 20703, 20705.5, 20718.75, 20727.25, 20730,
                        20722.5, 20721, 20727.25, 20741, 20744.5, 20754.25, 20753.75, 20751.25, 20751.25, 20750.5,
                        20751.75, 20752.5, 20756.75, 20755.5, 20759.75, 20759.25, 20754, 20755.5, 20757.25, 20756,
                        20752, 20752.5, 20752, 20751.75, 20751.5, 20751.5, 20751, 20754.25, 20751, 20755, 20753.5,
                        20753.5, 20752.5, 20754.5, 20746.25, 20738.5, 20733.5, 20723.25, 20719.5, 20722.5, 20715.75,
                        20719.5, 20724.25, 20724.75, 20722.75, 20723, 20716.25, 20709.75, 20711, 20712, 20709.5,
                        20708.75, 20712.5, 20713.5, 20713.5, 20708.5, 20707.5, 20706.75, 20699, 20702, 20702.75,
                        20699.75, 20694.5, 20687.5, 20685, 20687.25, 20687.25, 20685.5, 20680.25, 20683.5, 20687.25,
                        20684.75, 20692.25, 20693.25, 20700.25, 20696.5, 20703.5, 20698, 20699.5, 20691.75, 20684.5,
                        20683.75, 20663.25, 20660.25, 20665.75, 20669.75, 20668.5, 20662.75, 20660.25, 20661.75,
                        20654.75, 20653.25, 20649.5, 20666.25, 20651.5, 20647.75, 20652.25, 20655, 20658, 20665, 20664,
                        20668.25, 20670.75, 20666.25, 20653.75, 20649.75, 20652.25, 20638.75, 20637, 20642.25, 20642.5,
                        20647.5, 20649.75, 20650.5, 20650.5, 20648.25, 20650, 20656.5, 20655.5, 20654, 20654.5,
                        20648.75, 20650.25, 20663.25, 20668.75, 20667.5, 20665.25, 20665, 20667, 20665, 20651.5,
                        20643.75, 20647.25, 20651.5, 20646.75, 20650, 20646.75, 20654.5, 20652.5, 20666.5, 20667.75,
                        20658, 20652, 20646.75, 20641.25, 20638.75, 20637, 20630.25, 20630.75, 20632, 20628.25, 20625.5,
                        20631.25, 20640.75, 20633.5, 20636.25, 20638.75, 20635, 20639.5, 20631.25, 20633.5, 20637.5,
                        20640, 20643.25, 20642, 20640.75, 20642.75, 20641.25, 20640, 20642.5, 20644, 20644.25, 20645,
                        20650.5, 20656.75, 20653.25, 20652.5, 20652.25, 20647, 20647.5, 20650.75, 20650.75, 20650.5,
                        20659, 20656, 20652.25, 20648.75, 20652.25, 20648, 20652.25, 20650.5, 20654.5, 20653.75, 20652,
                        20652, 20647.5, 20644.25, 20638.5, 20644.25, 20653, 20652.75, 20650.25, 20653, 20652.5,
                        20651.75, 20653.5, 20649.25, 20644.75, 20645.25, 20650.5, 20647.5, 20647.75, 20647.75, 20652.5,
                        20655, 20655.5, 20658, 20659, 20660.25, 20664.25, 20665.25, 20664.5, 20663.5, 20664.5, 20664.75,
                        20660.5, 20661.5, 20663, 20669.5, 20675.75, 20673.75, 20674.75, 20673.25, 20674.5, 20679.25,
                        20682.5, 20684.75, 20683.75, 20687.5, 20684, 20683.75, 20685, 20686.5, 20684.5, 20683.5, 20683,
                        20684.75, 20684.25, 20686, 20686.25, 20685.25, 20684.75, 20685.5, 20678.25, 20675.25, 20674,
                        20679.25, 20673.5, 20672.25, 20673.5, 20675.25, 20677.5, 20672.25, 20671.75, 20671, 20663.75,
                        20656, 20655.75, 20656.75, 20656.75, 20651.5, 20653, 20654.75, 20648.25, 20643.25, 20644.75,
                        20652.75, 20654.5, 20656.25, 20661.75, 20664, 20668, 20669.75, 20668.25, 20675, 20678, 20679.75,
                        20678.5, 20677.25, 20674, 20676.25, 20676, 20675.5, 20677, 20676.25, 20675.75, 20675, 20674.25,
                        20674.75, 20670, 20672, 20671.25, 20667.25, 20669.5, 20669.75, 20677.25, 20677.25, 20676, 20677,
                        20678.5, 20679.25, 20677.25, 20675.5, 20677, 20677.5, 20680.5, 20680, 20681.5, 20677.75,
                        20676.5, 20678, 20680, 20681.25, 20676.75, 20678.25, 20679, 20682.75, 20680.25, 20682.5,
                        20680.25, 20681.25, 20678.25, 20677.25, 20678.75, 20678.75, 20677.5, 20677.25, 20680.5,
                        20684.25, 20686.5, 20684.75, 20683.75, 20684.75, 20683.5, 20683.25, 20681.5, 20681.25, 20682.5,
                        20685, 20693, 20695.25, 20693.25, 20695, 20696.25, 20696.5, 20697.75, 20702.25, 20703.5,
                        20700.5, 20702, 20698, 20696.75, 20698, 20693.25, 20692.25, 20692.75, 20690.75, 20690, 20684.25,
                        20678.75, 20675.5, 20673, 20674.25, 20672.5, 20662.5, 20669, 20674, 20676.5, 20678.25, 20676,
                        20675.25, 20676, 20676.75, 20677.75, 20678, 20678.5, 20680.5, 20678, 20676.5, 20679, 20677.75)
                .build();

        var wildersMa = new WildersMAIndicator(new ClosePriceIndicator(data), 14);

        double[] expectedDoubles = { 20581.1534970687, 20580.2318187066, 20579.2688316562, 20578.1960579664,
                20576.7356252546, 20576.9866520221, 20578.7376054491, 20580.9349193456, 20583.4574251066,
                20584.9961804561, 20587.5143104235, 20591.2632882504, 20594.601624804, 20597.8443658894,
                20602.7840540402, 20607.1744787516, 20611.8048731265, 20616.3902393317, 20620.7730793795,
                20625.5750022809, 20629.9803592609, 20634.6781907422, 20638.9868914035, 20643.5056848747,
                20647.0231359551, 20650.3964833868, 20653.1538774306, 20656.3214576142, 20659.4413534989,
                20661.6419711061, 20662.9532588842, 20664.2780261068, 20665.3831670992, 20665.9450837349,
                20665.2882920396, 20664.6962711796, 20664.1465375239, 20663.8860705579, 20663.1263512324,
                20661.40304043, 20659.7849661136, 20657.7110399626, 20655.7852513939, 20653.4970191515,
                20651.4079463549, 20649.5930930439, 20646.925729255, 20643.3417485939, 20639.7101951229,
                20636.0880383285, 20632.9388927336, 20630.1754003955, 20628.3057289386, 20627.4267483002,
                20627.5391234216, 20627.1791860343, 20627.398529889, 20627.4414920398, 20627.9635283227,
                20628.6625620139, 20628.7580932986, 20629.4182294916, 20630.2990702422, 20631.2062795106,
                20632.4594024027, 20633.5873022311, 20634.6167806431, 20635.7691534544, 20636.8927853505,
                20637.1504435397, 20636.8182690012, 20636.3133926439, 20635.9874360265, 20636.7026191675,
                20637.0452892269, 20637.2027685679, 20638.3132850987, 20639.005193306, 20640.3441080698,
                20641.194528922, 20640.7699197133, 20638.5542111623, 20637.3717675079, 20635.7737841145,
                20634.539942392, 20632.537089364, 20630.7308686951, 20629.9643780741, 20629.5026367831, 20628.55601987,
                20627.891304165, 20627.6312110103, 20627.1218387953, 20626.5595645957, 20625.8588814102,
                20624.8868184524, 20623.8056171343, 20623.0159301962, 20622.5326494679, 20622.3160316487,
                20622.2934579596, 20621.8260681053, 20621.5349203835, 20621.4788546418, 20621.6053650245,
                20620.4728389514, 20618.7069218834, 20616.299284606, 20615.3493357056, 20614.3065260123,
                20613.8560598686, 20614.2591984494, 20614.5978271316, 20615.0729823365, 20615.7999121696,
                20616.6534898718, 20617.4282405952, 20617.808366267, 20617.7684829622, 20617.1421627506,
                20616.7927225541, 20615.9682423717, 20615.5419393452, 20614.7175151062, 20613.8448354558,
                20612.2487757804, 20610.4810060818, 20609.1073627902, 20607.1711225909, 20604.3910424058,
                20601.8809679483, 20599.8001845234, 20597.6537427717, 20594.9999040023, 20592.4641965736,
                20591.0203253898, 20589.8581592905, 20588.8504336269, 20587.8432597964, 20586.8901698109,
                20585.7908719673, 20585.1629525411, 20584.6691702167, 20584.6928009155, 20584.8933151358,
                20584.9545069118, 20585.2970421324, 20584.9901105515, 20585.0622455121, 20585.3970851184,
                20585.8687218957, 20586.0566703317, 20585.8561938794, 20584.759322888, 20583.5443712532,
                20583.0769161637, 20582.1607078663, 20581.274228733, 20580.5582123949, 20579.768340081, 20579.409887218,
                20578.9877524168, 20578.881484387, 20578.1756640736, 20577.4309737827, 20576.6323327982,
                20575.9443090269, 20575.7518583821, 20575.1445827834, 20574.1342554417, 20573.1425229102,
                20572.2037712737, 20571.903501897, 20571.999680333, 20571.8211317377, 20571.7267651851,
                20571.7819962433, 20571.7797107973, 20571.7775885975, 20571.5613322691, 20571.7355228213,
                20572.5579854769, 20573.2859865143, 20574.5155589061, 20575.6751618414, 20576.698364567,
                20577.5591956694, 20579.0013959787, 20580.4655819802, 20582.0394689816, 20584.6080783401,
                20587.0825013158, 20589.3801797933, 20591.2815955223, 20593.2971958421, 20595.615253282,
                20597.3927351904, 20598.9539683911, 20599.9036849346, 20601.1248502964, 20601.4730752752,
                20601.9749984699, 20602.3517842934, 20602.5409425582, 20602.9487323755, 20603.2916800629,
                20603.6994172013, 20603.7030302584, 20604.1170995256, 20603.8051638452, 20603.8547949991,
                20603.9544524992, 20604.475563035, 20604.530879961, 20604.0643885352, 20604.1490750684,
                20604.6027125636, 20605.2203759519, 20605.9546348125, 20606.7435894687, 20606.9940473638,
                20607.387329695, 20608.1810918596, 20608.8467281553, 20609.5005332871, 20610.2326380523, 20610.91244962,
                20612.1865603614, 20613.5482346213, 20614.5090750055, 20615.6512839337, 20617.0869065099,
                20618.8664131877, 20620.8759551029, 20622.724101167, 20624.6366653693, 20626.8054749858,
                20630.2122267725, 20633.9292105745, 20638.4521241049, 20643.5805438117, 20649.0569335394,
                20654.2135811437, 20658.4126110621, 20663.3117102719, 20668.0215881096, 20672.1271889589,
                20676.1716754619, 20679.8558415003, 20682.5268528217, 20684.0963633345, 20686.0180516677,
                20687.3381908343, 20689.456891489, 20692.1742563826, 20695.2689523553, 20697.6604557585,
                20701.1489946329, 20703.7990664448, 20705.5277045559, 20707.8292970876, 20710.0200615814,
                20713.5364857541, 20716.391022486, 20718.3630923084, 20719.9978714292, 20722.3015948986,
                20725.887195263, 20729.8416813156, 20733.4422755074, 20736.8928272568, 20739.7576253099,
                20741.4892235021, 20743.9007075376, 20746.5506569992, 20748.1541814993, 20749.5003113922,
                20750.9110034356, 20752.5602174759, 20753.9487733705, 20754.6488609869, 20755.7096566307,
                20756.6768240142, 20757.6641937275, 20758.3131798898, 20759.1479527548, 20759.8516704152,
                20751.4694082427, 20742.8823076539, 20739.2121428215, 20739.0898469057, 20737.529857841,
                20734.5812965666, 20730.700489669, 20728.0790261212, 20724.0019528268, 20719.5018133392,
                20714.6802552436, 20709.9888084405, 20707.8467506947, 20706.6434113594, 20707.0617391194,
                20706.718043468, 20705.2203260775, 20704.4367313576, 20704.1198219749, 20703.2362632625,
                20702.487244458, 20702.4345841396, 20702.939256701, 20703.4257383652, 20704.020328482, 20706.0545907333,
                20707.8185485381, 20709.045795071, 20710.363952566, 20711.6772416684, 20712.5038672635, 20712.807162459,
                20713.3030794262, 20713.7100023243, 20714.2485735869, 20715.1058183307, 20716.2411170213,
                20717.4560372341, 20719.1913202888, 20720.5883688396, 20720.7606282082, 20720.6705833362,
                20721.0691130979, 20720.9570335909, 20721.602959763, 20722.238462637, 20722.6857153058,
                20723.2081642126, 20723.8004381974, 20724.1004068976, 20724.4682349763, 20724.1133610494,
                20723.301692403, 20722.4408572314, 20721.3557960006, 20719.6875248577, 20718.2812730821,
                20717.1183250048, 20716.3241589331, 20714.9438618664, 20714.0371574474, 20713.3559319154,
                20712.6162224929, 20712.1079208863, 20712.5823551087, 20713.6300440295, 20714.7993265988,
                20715.3493746989, 20715.7529907918, 20716.5742057353, 20718.3189053256, 20720.1889835166,
                20722.6219132654, 20724.8453480322, 20726.7313946013, 20728.4827235584, 20730.0553861613,
                20731.6050014355, 20733.097501333, 20734.7869655235, 20736.2664679861, 20737.94386313, 20739.4657300492,
                20740.5038921886, 20741.5750427465, 20742.6946825504, 20743.6450623682, 20744.2418436276,
                20744.8317119399, 20745.3437325156, 20745.8013230502, 20746.2083714038, 20746.5863448749,
                20746.9016059553, 20747.4264912442, 20747.6817418696, 20748.2044745932, 20748.582726408,
                20748.933960236, 20749.188677362, 20749.5680575504, 20749.3310534397, 20748.5574067654,
                20747.4818777107, 20745.7510293028, 20743.8759557812, 20742.3491017968, 20740.4491659542,
                20738.9527969575, 20737.9025971748, 20736.963125948, 20735.947902666, 20735.0230524756,
                20733.6821201559, 20731.9726830019, 20730.4746342161, 20729.1550174863, 20727.7510876659,
                20726.3938671183, 20725.4014480384, 20724.5513446071, 20723.7619628495, 20722.6718226459,
                20721.5881210284, 20720.5282552406, 20718.9905227234, 20717.7769139575, 20716.7035629605,
                20715.4925941776, 20713.9931231649, 20712.1007572246, 20710.1649888514, 20708.5282039334,
                20707.0083322239, 20705.4720227794, 20703.6704497237, 20702.2297033149, 20701.1597245066,
                20699.9876013276, 20699.4349155185, 20698.9931358386, 20699.0829118501, 20698.8984181465,
                20699.2271025646, 20699.1394523815, 20699.1652057828, 20698.6355482269, 20697.6258662107,
                20696.6347329099, 20694.2501091306, 20691.821529907, 20689.9592777708, 20688.51575793, 20687.086060935,
                20685.3477708682, 20683.5550729491, 20681.9975677384, 20680.0513129, 20678.1369334071, 20676.0914381638,
                20675.3884782949, 20673.6821584167, 20671.8298613869, 20670.4312998593, 20669.3290641551,
                20668.5198452868, 20668.2684277664, 20667.9635400688, 20667.9840014924, 20668.1815728144,
                20668.0436033277, 20667.0226316614, 20665.788872257, 20664.8218099529, 20662.9595378134,
                20661.1052851125, 20659.758479033, 20658.5257305307, 20657.7381783499, 20657.167594182,
                20656.6913374548, 20656.2490990651, 20655.6777348462, 20655.2721823572, 20655.3598836174,
                20655.3698919304, 20655.2720425068, 20655.2168966135, 20654.7549754268, 20654.4331914677,
                20655.0629635058, 20656.0406089696, 20656.8591369004, 20657.4584842646, 20657.99716396,
                20658.6402236772, 20659.0944934145, 20658.5520295992, 20657.4947417707, 20656.7629745013,
                20656.3870477512, 20655.6986871976, 20655.291638112, 20654.681521104, 20654.6685553109, 20654.513658503,
                20655.3698257528, 20656.2541239133, 20656.378829348, 20656.0660558232, 20655.4006232644,
                20654.3898644598, 20653.2727312841, 20652.1103933352, 20650.5489366684, 20649.1347269064,
                20647.9108178416, 20646.5064737101, 20645.0060113022, 20644.0234390664, 20643.7896219902,
                20643.0546489909, 20642.5686026344, 20642.2958453034, 20641.774713496, 20641.6122339606,
                20640.8720743919, 20640.3454976497, 20640.1422478175, 20640.1320872592, 20640.3547953121,
                20640.4723099326, 20640.4921449375, 20640.6534202991, 20640.6960331348, 20640.6463164824,
                20640.7787224479, 20641.0088137016, 20641.2403270086, 20641.5088750795, 20642.1510982881,
                20643.1938769818, 20643.9121714831, 20644.5255878057, 20645.0773315339, 20645.2146649957,
                20645.3779032103, 20645.7616244096, 20646.1179369518, 20646.4309414552, 20647.3287313513,
                20647.9481076833, 20648.2553857059, 20648.2907152984, 20648.5735213485, 20648.5325555379,
                20648.7980872852, 20648.9196524791, 20649.3182487306, 20649.6348023927, 20649.8037450789,
                20649.9606204304, 20649.7848618283, 20649.3895145548, 20648.6116920866, 20648.3001426519,
                20648.6358467481, 20648.9297148376, 20649.0240209206, 20649.3080194263, 20649.5360180387,
                20649.6941596073, 20649.9660053497, 20649.9148621104, 20649.5459433882, 20649.2390902891,
                20649.3291552684, 20649.1985013207, 20649.0950369406, 20648.9989628735, 20649.2490369539,
                20649.6598200286, 20650.0769757409, 20650.6429060451, 20651.2398413276, 20651.8834240899,
                20652.7667509406, 20653.6584115877, 20654.43281076, 20655.0804671343, 20655.7532909104,
                20656.3959129883, 20656.6890620605, 20657.0327004848, 20657.4589361644, 20658.3190121527,
                20659.5640827132, 20660.5773625194, 20661.589693768, 20662.4225727846, 20663.2852461571,
                20664.4255857173, 20665.716615309, 20667.0761427869, 20668.2671325878, 20669.6409088315,
                20670.6665582007, 20671.6010897578, 20672.5581547751, 20673.5540008626, 20674.3358579438,
                20674.9904395193, 20675.5625509822, 20676.2187973406, 20676.7924546734, 20677.4501364825,
                20678.0786981623, 20678.5909340078, 20679.030867293, 20679.4929482006, 20679.4041661863,
                20679.1074400301, 20678.7426228851, 20678.7788641076, 20678.4018023856, 20677.9623879295,
                20677.6436459346, 20677.472671225, 20677.4746232803, 20677.1014359031, 20676.7191904815,
                20676.3106768757, 20675.4134856703, 20674.0268081224, 20672.7213218279, 20671.5805131259,
                20670.5211907598, 20669.162534277, 20668.0080675429, 20667.0610627184, 20665.7174153814,
                20664.112599997, 20662.7295571401, 20662.0167316301, 20661.4798222279, 20661.1062634973,
                20661.1522446761, 20661.3556557707, 20661.8302517871, 20662.395948088, 20662.8140946531,
                20663.6845164636, 20664.7070510019, 20665.7815473589, 20666.6900082619, 20667.444293386,
                20667.9125581442, 20668.5080897053, 20669.0432261549, 20669.5044242867, 20670.0398225519,
                20670.4834066554, 20670.8595918943, 20671.1553353304, 20671.3763828068, 20671.6173554635,
                20671.5018300732, 20671.5374136394, 20671.5168840937, 20671.2121066585, 20671.0898133257,
                20670.9941123739, 20671.44096149, 20671.8558928122, 20672.1519004684, 20672.4981932921,
                20672.9268937713, 20673.3785442162, 20673.6550767722, 20673.7868570027, 20674.0163672168,
                20674.2651981299, 20674.7105411206, 20675.088359612, 20675.5463339254, 20675.703738645,
                20675.7606144561, 20675.9205705664, 20676.2119583831, 20676.5718184986, 20676.5845457487,
                20676.7035067666, 20676.8675419976, 20677.2877175692, 20677.4993091714, 20677.8565013734,
                20678.027465561, 20678.2576465924, 20678.2571004072, 20678.1851646639, 20678.225510045,
                20678.2629736132, 20678.208475498, 20678.1400129624, 20678.3085834651, 20678.7329703605,
                20679.2877581918, 20679.677918321, 20679.9687812981, 20680.3102969196, 20680.5381328539,
                20680.7318376501, 20680.7867063894, 20680.8197987901, 20680.9398131623, 20681.2298265078,
                20682.0705531858, 20683.011942244, 20683.7432320837, 20684.5472869349, 20685.3831950109,
                20686.1772525102, 20687.0038773309, 20688.092886093, 20689.1933942292, 20690.0010089271,
                20690.858079718, 20691.368216881, 20691.7526299609, 20692.198870678, 20692.2739513439, 20692.2722405336,
                20692.3063662098, 20692.1951971948, 20692.0383973952, 20691.4820832955, 20690.5726487744,
                20689.4960310048, 20688.3177430759, 20687.3129042847, 20686.254839693, 20684.5580654292,
                20683.4467750414, 20682.7720053956, 20682.3240050102, 20682.0330046523, 20681.6020757486,
                20681.1483560522, 20680.7806163342, 20680.4927151675, 20680.2968069412, 20680.1327493026,
                20680.0161243524, 20680.0506868987, 20679.904209263, 20679.6610514585, 20679.6138334972,
                20679.4807025331,

        };

        // skip the first 100 due to inaccuracies of the Wilder's calculation
        // See WildersMAIndicator.java javaDoc
        // @ element 101 the data starts to stabilize to 0.0001d
        for (int i = 101; i < data.getBarCount(); i++) {
            assertNumEquals(expectedDoubles[i], wildersMa.getValue(i));
        }

    }

}
